import Trans from '../../../main/js/com/1110111011101110/Trans.js'
import Row from '../../../main/js/com/1110111011101110/basics/Row.js'
import StrTo from '../utils/StrTo.js'
import fs from 'fs';

let trans= new  Trans()
let fsPath="./测试.jsr"
let data=fs.readFileSync(fsPath);
trans.loadData(data)



class Run{
  static  run(str){

   let wordIds= this. word(str);

    console.log("数据文字  "+str   +"       数据ID："+wordIds)
    let wordsId=  this.words(wordIds)
      debugger
      console.table("词 ："+wordsId.toString())
  }

    analysis(){

    }


    /**
     * 字
     * @param strNums
     */
  static word(str){
        //拆分直接添加
        let res=[];
        let srts=str.split("");
        for(let i=0;i<srts.length;i++){
            let num= StrTo.utf8ToNum(srts[i]);
            let wordId =trans.addWord(num);
            res.push(wordId)
        }
        return res;

  }

    /**
     * 通过字或者词添加意
     * 意
     */
 idea(){
        //判断是字还是词
    //    如果是词查找是否存在，不存在创建
        //查找意是否存在，不存在创建

    }

    /**
     * 组词
     */
    static words(wordIds){
      return  trans.addWrods(wordIds[0],wordIds[1])
        //查找每个字是否存在
        //组词 某认情况下不创建，除非添加意
    }

    /**
     *
     * @param str 字符
     * @param field 空间
     * @param act 动作
     * @param state 状态
     */
    static idea(str,field,act,state){
        let wordIds= this. word(str);
        let wordsIds= this. word(field);
        let idesssIdss=this.words(wordsIds);
        let conditionIds= this. word(act);
        let conditionIdss=this.words(conditionIds);

      let row =new Row(idesssIdss.find(3),conditionIdss.find(3),state,5);
        trans.addReal(row,wordIds[0])

     let real=   trans.findReal(null,wordIds[0])
        debugger
        console.log("xxxxx")
    }


}


Run.idea('和', '转换' ,'分词', '1')
